import { GetServerSideProps, NextPage, PageConfig } from 'next';
import Head from 'next/head';
import Content from './content';
import { Message as M1 } from '../../api/admin/role/query.api';
import getallmenues from '../menu/getallmenus';

interface IProps {
	query: M1;
	menus: ITbfdmenu[];
}

/**
 * 用户角色维护
 */
const Page: NextPage<IProps> = (context) => {
	const { query, menus } = context;
	return (
		<>
			<Head>
				<title>用户角色维护</title>
			</Head>
			<Content initialquery={query} menus={menus} />
		</>
	);
};

export const config: PageConfig = {
	amp: false
};

export default Page;

export const getServerSideProps: GetServerSideProps<IProps> = async (context) => {
	const query = context.query as Record<string, string>;
	const menus = await getallmenues();
	return {
		props: {
			query: {
				page: query.page || '1',
				pagesize: '10',
				q: query.q || ''
			},
			menus
		}
	};
};
